home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / networking / otpapsampleserver / enableselfsendsample.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  3.1 KB  |  89 lines

  1. /*
  2.     File: EnableSelfSendSample.c
  3.     By:        Rich Kubota
  4.             Developer Technical Support
  5.     
  6.     Purpose: Demonstrate the use of the OTOptionManagement call to tell an AppleTalk
  7.             endpoint to enable/disable the SelfSend option.
  8.     change history:
  9.             9/14/98 rrk Modified check for asynch mode. Return err -1, instead of using 
  10.                 classic AppleTalk SelfSend call.
  11.                     
  12.                 Note that this sample does not support asynch endpoints.  To support
  13.                 an asynch endpoint, the same call to OTOptionManagement would happen
  14.                 however, the endpoint handler will be called with the
  15.                 T_OPTMGMTCOMPLETE event.  The handler would then inspect the cookie, 
  16.                 which will be the TOptMgmt "ret" value to check for the
  17.                 success or failure of the call.
  18.  
  19.             1/25/98    rrk Changed the original use of the OTOptionManagement call, OPT_SELFSEND
  20.                 which only enables selfsend from the endpoint to other AppleTalk services when
  21.                 broadcast messages are sent from the endpoint.  The desired behavior is one 
  22.                 where if other AppleTalk clients on the node send broadcast messages, that they
  23.                 are also sent to the endpoint.  To this end, there is the ATALK_IOC_FULLSELFSEND
  24.                 Ioct, which must be sent to the DDP endpoint.
  25.                 
  26.                 Note that the ATALK_IOC_FULLSELFSEND is desired to respond similarly to the 
  27.                 PSetSelfSend function.  If the result is not negative, then the following responses
  28.                 can be expected.
  29.                 
  30.                 0 - FullSelfSend was previously off
  31.                 1 - FullSelfSend was previously on
  32.                 
  33.                 Input parameters
  34.                 
  35.                 ep - the AppleTalk EndpointRef on which to enable fullSelfSend. You can pass
  36.                 any AppleTalk endpoint, DDP or above, to this function.
  37.                 
  38.                 enableSelfSend - a long word of the desired setting.
  39.                 
  40.                 Return result
  41.                 < 0 - error
  42.                 0 - FullSelfSend was previously off
  43.                 1 - FullSelfSend was previously on
  44.                 
  45.                 Note that if the use of the Ioctl returns an error < 0, then the PBSetSelfSend
  46.                 function is called.
  47.                 
  48.                 Note: As with the PSetSelfSend call, the Ioctl call affects AppleTalk globally.
  49.                 If you enable this feature, it is recommended that you not disable the feature
  50.                 when the process quits.  The user may launch another process which enables 
  51.                 selfsend.  Turning off selfsend in this case, affects the other process, as well.
  52. */
  53.  
  54. #include "OpenTransport.h"            // open transport files            
  55. #include "OpenTptAppletalk.h"
  56. #include "AppleTalk.h"
  57.  
  58. extern OSStatus DoNegotiateSelfSendOption(EndpointRef ep, long enableSelfSend);
  59.  
  60.  
  61. /*
  62.     Sample function to enable/disable the SelfSend option for 
  63.     an AppleTalk endpoint. 
  64.  
  65.     Input
  66.     EndpointRef ep - endpoint on which to set SelfSend option on
  67.     long enableSelfSend - 1L - option on, 0L - option off
  68.  
  69.    Return: 0 - indicates call success
  70.               -1 - asynch endpoints are not supported 
  71.            other negative result - error calling OTIoctl
  72.     
  73. */
  74. OSStatus DoNegotiateSelfSendOption(EndpointRef ep, long enableSelfSend)
  75.  
  76. {
  77.     OSStatus        result;
  78.     
  79.     if (OTIsSynchronous(ep) == false)            // check whether ep sync or not
  80.     {
  81.         DebugStr("\pThis routine does not support asynch endpoints");
  82.         return (OSStatus)-1;
  83.     }
  84.                 
  85.     result = OTIoctl(ep, ATALK_IOC_FULLSELFSEND, (void*)enableSelfSend);
  86.     
  87.     return result;
  88. }
  89.